package com.example.skillcinema.db.localdb.tables

import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.ForeignKey

@Entity(
    tableName = "film_collections",
    primaryKeys = ["film_id", "collection_id"],
    foreignKeys = [
        ForeignKey(
            entity = FilmEntity::class,
            parentColumns = ["film_id"],
            childColumns = ["film_id"],
            onDelete = ForeignKey.CASCADE
        ),
        ForeignKey(
            entity = CollectionEntity::class,
            parentColumns = ["collection_id"],
            childColumns = ["collection_id"],
            onDelete = ForeignKey.CASCADE
        )
    ]
)
data class FilmCollectionCrossRef(
    @ColumnInfo(name = "film_id")
    val filmId: Int,
    @ColumnInfo(name = "collection_id")
    val collectionId: Int,
    @ColumnInfo(name = "added_date")
    val addedDate: Long = System.currentTimeMillis()
)
